Cosmos: fix #2616 by using RawValue, and fix query rewriting #2617
+26
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #2616
It's a tale as old as time. Abstraction is written, then implemented, and found lacking somewhere ;). This PR has a few small fix-ups for the query engine abstraction that I found while integrating the query engine. Once these were fixed, it worked perfectly though! 🎉
Here are the changes:
The query engine works with
serde_json::value::RawValue
, which represents "unparsed" JSON. It's just a wrapper aroundstr
, and I had hoped it would be easy to consume it and convert it in to aVec<u8>
, so that's what I had the QueryPipeline abstraction expect as a result from the pipeline. Alas, it's not really possible to do that. You can access the underlying bytes viaRawValue::get()
but that returns&str
and there's no way to "move" the bytes out of theRawValue
. But that's OK, we can just have the pipeline send backBox<RawValue>
values directly, since the pipeline is always working with JSON anyway. So, that's what I did. (This is #2616, which I filed when I thought I could work around it and fix the SDK later, but I couldn't do that with the below issue so I decided to just fix them both here first).There was also a bug in how the query "executor" worked. I built the base query request as soon as the pipeline was created, using the query the user passed in. But the gateway may rewrite the query. The query engine handles this and exposes the "authoritative" query out of
QueryPipeline::query()
, but the SDK's executor ignored that and used the original query. A pretty simple fix.